package org.javaboy;

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;

public class Demo04 {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3};
        IntStream.of(arr).forEach(System.out::println);
        int sum = IntStream.of(arr).sum();
        System.out.println("sum = " + sum);
        int sum1 = IntStream.of(arr).map(i -> (int) Math.pow(i, 2)).sum();
        System.out.println("sum1 = " + sum1);

        List<String> list = Arrays.asList("a", "b", "c");
        list.stream().forEach(System.out::println);
    }
}
